package com.coda.app.controller;

import ch.qos.logback.core.rolling.helper.IntegerTokenConverter;
import com.coda.app.service.RoomService;
import com.coda.appVo.room.RoomDetailVo;
import com.coda.appVo.room.RoomItemVo;
import com.coda.appVo.room.RoomQueryVo;
import com.coda.result.PageResult;
import com.coda.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/app/room")
@Api(tags = "房间信息")
public class RoomController {

    @Autowired
    private RoomService roomService;

    /**
     * 分页查询房间列表
     */
    @GetMapping("/pageItem")
    @ApiOperation("分页查询房间列表")
    public Result<PageResult> getPage(@RequestParam Integer current,
                                      @RequestParam Integer size,
                                      RoomQueryVo roomQueryVo) {
        PageResult pageResult = roomService.getPage(current, size, roomQueryVo);
        return Result.ok(pageResult);
    }

    /**
     * 根据id查询房间详细信息
     */
    @GetMapping("/getDetailById")
    @ApiOperation("根据id查询房间详细信息")
    public Result<RoomDetailVo> getDetail(@RequestParam Long id) {
        RoomDetailVo roomDetailVo = roomService.getDetailById(id);
        return Result.ok(roomDetailVo);
    }

    /**
     * 根据公寓id分页查询房间列表
     */
    @GetMapping("/pageItemByApartmentId")
    @ApiOperation("根据公寓id分页查询房间列表")
    public Result<PageResult> getPageByApratId(@RequestParam Integer current,
                                               @RequestParam Integer size,
                                               @RequestParam Long id) {
        PageResult pageResult = roomService.getPageByApratId(current, size, id);
        return Result.ok(pageResult);
    }
}
